<template>
  <div class="detailaction">
    <van-goods-action>
      <van-goods-action-icon icon="chat-o" text="客服" dot />
      <van-goods-action-icon icon="cart-o" text="购物车" :badge="cartNum" @click="goCart" />
      <van-goods-action-icon icon="shop-o" text="店铺" badge="12" />
      <van-goods-action-button type="warning" text="加入购物车" @click.native="add" />
      <van-goods-action-button type="danger" text="立即购买" />
    </van-goods-action>
  </div>
</template>

<script>
export default {
  name: "DetailAction",
  data(){
    return{
      
    }
  },
  computed:{
    cartNum(){
      if(this.$store.state.cart){
        return this.$store.state.cart.length
      }
    }
  },
  methods:{
    add(){
      this.$bus.$emit('open')
      
    },
    goCart(){
      this.$router.push('/cart')
    }
  },
  created(){
    this.$store.dispatch("updateUser");
    this.$store.dispatch("updateCart");
    
    
  }
};
</script>

<style lang="less" scoped>
</style>